<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.3/css/all.min.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.1.1/animate.min.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.css">
  <script src="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.js"></script>

<script class="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"ackermannn.github.io","root":"/","images":"/images","scheme":"Gemini","version":"8.3.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":true,"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}};
  </script>
<meta property="og:type" content="website">
<meta property="og:title" content="Ackermannn&#39;s Blog">
<meta property="og:url" content="http://ackermannn.github.io/page/2/index.html">
<meta property="og:site_name" content="Ackermannn&#39;s Blog">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="Ackermannn">
<meta name="twitter:card" content="summary">


<link rel="canonical" href="http://ackermannn.github.io/page/2/">


<script data-pjax class="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : true,
    isPost : false,
    lang   : 'zh-CN'
  };
</script>
<title>Ackermannn's Blog</title>
  




  <noscript>
  <style>
  body { margin-top: 2rem; }

  .use-motion .menu-item,
  .use-motion .sidebar,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header {
    visibility: visible;
  }

  .use-motion .header,
  .use-motion .site-brand-container .toggle,
  .use-motion .footer { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle,
  .use-motion .custom-logo-image {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line {
    transform: scaleX(1);
  }

  .search-pop-overlay, .sidebar-nav { display: none; }
  .sidebar-panel { display: block; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <h1 class="site-title">Ackermannn's Blog</h1>
      <i class="logo-line"></i>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu">
        <li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li>
        <li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a></li>
        <li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a></li>
        <li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-overview-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="Ackermannn"
      src="/images/dl.jpg">
  <p class="site-author-name" itemprop="name">Ackermannn</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">22</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">2</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">14</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author site-overview-item animated">
      <span class="links-of-author-item">
        <a href="https://github.com/ackermannn" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;ackermannn" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>



        </div>
      </div>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner index posts-expand">

    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://ackermannn.github.io/2021/04/24/%E5%8A%9B%E6%89%A3377-%E7%BB%84%E5%90%88%E7%BB%BC%E5%90%88%E2%85%A3/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/dl.jpg">
      <meta itemprop="name" content="Ackermannn">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Ackermannn's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2021/04/24/%E5%8A%9B%E6%89%A3377-%E7%BB%84%E5%90%88%E7%BB%BC%E5%90%88%E2%85%A3/" class="post-title-link" itemprop="url">力扣377.组合综合Ⅳ</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2021-04-24 09:55:27" itemprop="dateCreated datePublished" datetime="2021-04-24T09:55:27+08:00">2021-04-24</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2021-09-01 15:23:22" itemprop="dateModified" datetime="2021-09-01T15:23:22+08:00">2021-09-01</time>
      </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%8A%9B%E6%89%A3/" itemprop="url" rel="index"><span itemprop="name">力扣</span></a>
        </span>
    </span>

  
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Changyan：</span>
    
    
      <a title="changyan" href="/2021/04/24/%E5%8A%9B%E6%89%A3377-%E7%BB%84%E5%90%88%E7%BB%BC%E5%90%88%E2%85%A3/#SOHUCS" itemprop="discussionUrl">
        <span id="url::http://ackermannn.github.io/2021/04/24/%E5%8A%9B%E6%89%A3377-%E7%BB%84%E5%90%88%E7%BB%BC%E5%90%88%E2%85%A3/" class="cy_cmt_count" data-xid="2021/04/24/力扣377-组合综合Ⅳ/" itemprop="commentCount"></span>
      </a>
    
  </span>
  
  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h1 id="题目"><a href="#题目" class="headerlink" title="题目"></a>题目</h1><p>给你一个由 不同 整数组成的数组 nums ，和一个目标整数 target 。请你从 nums 中找出并返回总和为 target 的元素组合的个数。</p>
<p>题目数据保证答案符合 32 位整数范围。</p>
<p><strong>示例 1：</strong></p>
<figure class="highlight nix"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">输入：<span class="attr">nums</span> = [<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>], <span class="attr">target</span> = <span class="number">4</span></span><br><span class="line">输出：<span class="number">7</span></span><br><span class="line">解释：</span><br><span class="line">所有可能的组合为：</span><br><span class="line">(<span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>)</span><br><span class="line">(<span class="number">1</span>, <span class="number">1</span>, <span class="number">2</span>)</span><br><span class="line">(<span class="number">1</span>, <span class="number">2</span>, <span class="number">1</span>)</span><br><span class="line">(<span class="number">1</span>, <span class="number">3</span>)</span><br><span class="line">(<span class="number">2</span>, <span class="number">1</span>, <span class="number">1</span>)</span><br><span class="line">(<span class="number">2</span>, <span class="number">2</span>)</span><br><span class="line">(<span class="number">3</span>, <span class="number">1</span>)</span><br><span class="line">请注意，顺序不同的序列被视作不同的组合。</span><br></pre></td></tr></table></figure>

<p><strong>示例 2：</strong></p>
<figure class="highlight nix"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">输入：<span class="attr">nums</span> = [<span class="number">9</span>], <span class="attr">target</span> = <span class="number">3</span></span><br><span class="line">输出：<span class="number">0</span></span><br></pre></td></tr></table></figure>

<p><strong>提示：</strong></p>
<figure class="highlight apache"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">1</span> &lt;= nums.length &lt;= <span class="number">200</span></span><br><span class="line"><span class="attribute">1</span> &lt;= nums[i] &lt;= <span class="number">1000</span></span><br><span class="line"><span class="attribute">nums</span> 中的所有元素 互不相同</span><br><span class="line"><span class="attribute">1</span> &lt;= target &lt;= <span class="number">1000</span></span><br></pre></td></tr></table></figure>

<p><strong>进阶：</strong>如果给定的数组中含有负数会发生什么？问题会产生何种变化？如果允许负数出现，需要向题目中添加哪些限制条件？</p>
<p>来源：力扣（LeetCode）</p>
<p>链接：<a target="_blank" rel="noopener" href="https://leetcode-cn.com/problems/combination-sum-iv">https://leetcode-cn.com/problems/combination-sum-iv</a></p>
<h1 id="解答"><a href="#解答" class="headerlink" title="解答"></a>解答</h1><p>递归。加上lru_cache后不会超时</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Solution</span>:</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">combinationSum4</span>(<span class="params">self, nums: <span class="type">List</span>[<span class="built_in">int</span>], target: <span class="built_in">int</span></span>) -&gt; <span class="built_in">int</span>:</span></span><br><span class="line">        self.nums = nums</span><br><span class="line">        <span class="keyword">return</span> self.recur(target)</span><br><span class="line"></span><br><span class="line"><span class="meta">    @lru_cache(<span class="params"><span class="number">1000</span> * <span class="number">1000</span></span>)</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">recur</span>(<span class="params">self, target</span>):</span></span><br><span class="line">        ret = <span class="number">0</span></span><br><span class="line">        <span class="keyword">if</span> target == <span class="number">0</span>:</span><br><span class="line">            <span class="keyword">return</span> <span class="number">1</span></span><br><span class="line">        <span class="keyword">for</span> x <span class="keyword">in</span> self.nums:</span><br><span class="line">            <span class="keyword">if</span> x &lt;= target:</span><br><span class="line">                ret += self.recur(target - x)</span><br><span class="line">        <span class="keyword">return</span> ret</span><br></pre></td></tr></table></figure>

<p>动态规划</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Solution</span>:</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">combinationSum4</span>(<span class="params">self, nums: <span class="type">List</span>[<span class="built_in">int</span>], target: <span class="built_in">int</span></span>) -&gt; <span class="built_in">int</span>:</span></span><br><span class="line">        dp = [<span class="number">1</span>] + [<span class="number">0</span>] * target</span><br><span class="line">        <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="number">1</span>, target + <span class="number">1</span>):</span><br><span class="line">            <span class="keyword">for</span> x <span class="keyword">in</span> nums:</span><br><span class="line">                <span class="keyword">if</span> x &lt;= i:</span><br><span class="line">                    dp[i] += dp[i - x]</span><br><span class="line">        <span class="keyword">return</span> dp[target]</span><br><span class="line"></span><br></pre></td></tr></table></figure>

      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://ackermannn.github.io/2021/04/23/%E5%8A%9B%E6%89%A369-x%E7%9A%84%E5%B9%B3%E6%96%B9%E6%A0%B9/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/dl.jpg">
      <meta itemprop="name" content="Ackermannn">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Ackermannn's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2021/04/23/%E5%8A%9B%E6%89%A369-x%E7%9A%84%E5%B9%B3%E6%96%B9%E6%A0%B9/" class="post-title-link" itemprop="url">力扣69.x的平方根</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2021-04-23 19:48:56" itemprop="dateCreated datePublished" datetime="2021-04-23T19:48:56+08:00">2021-04-23</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2021-09-01 15:23:22" itemprop="dateModified" datetime="2021-09-01T15:23:22+08:00">2021-09-01</time>
      </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%8A%9B%E6%89%A3/" itemprop="url" rel="index"><span itemprop="name">力扣</span></a>
        </span>
    </span>

  
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Changyan：</span>
    
    
      <a title="changyan" href="/2021/04/23/%E5%8A%9B%E6%89%A369-x%E7%9A%84%E5%B9%B3%E6%96%B9%E6%A0%B9/#SOHUCS" itemprop="discussionUrl">
        <span id="url::http://ackermannn.github.io/2021/04/23/%E5%8A%9B%E6%89%A369-x%E7%9A%84%E5%B9%B3%E6%96%B9%E6%A0%B9/" class="cy_cmt_count" data-xid="2021/04/23/力扣69-x的平方根/" itemprop="commentCount"></span>
      </a>
    
  </span>
  
  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h1 id="题目"><a href="#题目" class="headerlink" title="题目"></a>题目</h1><p>实现 <code>int sqrt(int x)</code> 函数。</p>
<p>计算并返回 <code>x</code> 的平方根，其中 <code>x</code> 是非负整数。</p>
<p>由于返回类型是整数，结果只保留整数的部分，小数部分将被舍去。</p>
<p>示例 1:</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">输入: 4</span></span><br><span class="line"><span class="section">输出: 2</span></span><br></pre></td></tr></table></figure>

<p>示例 2:</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">输入: 8</span></span><br><span class="line"><span class="section">输出: 2</span></span><br><span class="line"><span class="section">说明: 8 的平方根是 2.82842..., </span></span><br><span class="line">     由于返回类型是整数，小数部分将被舍去。</span><br></pre></td></tr></table></figure>

<p>链接：</p>
<p><a target="_blank" rel="noopener" href="https://leetcode-cn.com/problems/sqrtx/">https://leetcode-cn.com/problems/sqrtx/</a></p>
<h1 id="解答"><a href="#解答" class="headerlink" title="解答"></a>解答</h1><h2 id="二分查找"><a href="#二分查找" class="headerlink" title="二分查找"></a>二分查找</h2><p>二分法是符合计算机思想的解法。</p>
<p>二分查找的下界为 0，上界可以粗略地设定为 x。在二分查找的每一步中，我们只需要比较中间元素 bit 的平方与 x 的大小关系，并通过比较的结果调整上下界的范围。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Solution</span>:</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">mySqrt</span>(<span class="params">self, x: <span class="built_in">int</span></span>) -&gt; <span class="built_in">int</span>:</span></span><br><span class="line">        <span class="keyword">if</span> x == <span class="number">0</span>: <span class="keyword">return</span> <span class="number">0</span></span><br><span class="line">        small = <span class="number">1</span></span><br><span class="line">        big = x</span><br><span class="line">        <span class="keyword">while</span> big - small &gt; <span class="number">1</span>:</span><br><span class="line">            bit = (small + big) // <span class="number">2</span></span><br><span class="line">            <span class="keyword">if</span> bit ** <span class="number">2</span> == x:</span><br><span class="line">                <span class="keyword">return</span> bit</span><br><span class="line">            <span class="keyword">elif</span> bit ** <span class="number">2</span> &lt; x:</span><br><span class="line">                small = bit</span><br><span class="line">            <span class="keyword">elif</span> bit ** <span class="number">2</span> &gt; x:</span><br><span class="line">                big = bit</span><br><span class="line"></span><br><span class="line">        <span class="keyword">return</span> <span class="built_in">int</span>(small)</span><br></pre></td></tr></table></figure>

<h2 id="牛顿法"><a href="#牛顿法" class="headerlink" title="牛顿法"></a>牛顿法</h2><p>这个题解说的比较好：</p>
<p><a href="https://link.zhihu.com/?target=https%3A//leetcode-cn.com/problems/sqrtx/solution/niu-dun-die-dai-fa-by-loafer/">https://link.zhihu.com/?target=https%3A//leetcode-cn.com/problems/sqrtx/solution/niu-dun-die-dai-fa-by-loafer/</a></p>
<p>该方法比较适合机器学习背景。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Solution</span>:</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">mySqrt</span>(<span class="params">self, x: <span class="built_in">int</span></span>) -&gt; <span class="built_in">int</span>:</span></span><br><span class="line">        r = x</span><br><span class="line">        <span class="keyword">while</span> r * r &gt; x:</span><br><span class="line">            r = (r + x / r) // <span class="number">2</span></span><br><span class="line">        <span class="keyword">return</span> <span class="built_in">int</span>(r)</span><br></pre></td></tr></table></figure>










      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://ackermannn.github.io/2021/04/23/%E5%AE%9E%E7%94%A8python%E5%B0%8F%E5%B7%A5%E5%85%B7-%E5%87%BD%E6%95%B0%E8%BF%90%E8%A1%8C%E6%97%B6%E9%97%B4%E8%A3%85%E9%A5%B0%E5%99%A8/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/dl.jpg">
      <meta itemprop="name" content="Ackermannn">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Ackermannn's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2021/04/23/%E5%AE%9E%E7%94%A8python%E5%B0%8F%E5%B7%A5%E5%85%B7-%E5%87%BD%E6%95%B0%E8%BF%90%E8%A1%8C%E6%97%B6%E9%97%B4%E8%A3%85%E9%A5%B0%E5%99%A8/" class="post-title-link" itemprop="url">实用python小工具--函数运行时间装饰器</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2021-04-23 19:33:48" itemprop="dateCreated datePublished" datetime="2021-04-23T19:33:48+08:00">2021-04-23</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2021-09-01 15:23:22" itemprop="dateModified" datetime="2021-09-01T15:23:22+08:00">2021-09-01</time>
      </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/python/" itemprop="url" rel="index"><span itemprop="name">python</span></a>
        </span>
    </span>

  
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Changyan：</span>
    
    
      <a title="changyan" href="/2021/04/23/%E5%AE%9E%E7%94%A8python%E5%B0%8F%E5%B7%A5%E5%85%B7-%E5%87%BD%E6%95%B0%E8%BF%90%E8%A1%8C%E6%97%B6%E9%97%B4%E8%A3%85%E9%A5%B0%E5%99%A8/#SOHUCS" itemprop="discussionUrl">
        <span id="url::http://ackermannn.github.io/2021/04/23/%E5%AE%9E%E7%94%A8python%E5%B0%8F%E5%B7%A5%E5%85%B7-%E5%87%BD%E6%95%B0%E8%BF%90%E8%A1%8C%E6%97%B6%E9%97%B4%E8%A3%85%E9%A5%B0%E5%99%A8/" class="cy_cmt_count" data-xid="2021/04/23/实用python小工具-函数运行时间装饰器/" itemprop="commentCount"></span>
      </a>
    
  </span>
  
  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <p>装饰器定义如下：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">import time</span><br><span class="line">def CalculateTime(a_func):</span><br><span class="line">    def wrapTheFunction():</span><br><span class="line">        start &#x3D; time.time()</span><br><span class="line">        a_func()</span><br><span class="line">        cost &#x3D; time.time() - start</span><br><span class="line">        print(f&quot;Function \&quot;&#123;a_func.__name__&#125;\&quot; cost : &#123;cost&#125; second(s).&quot;)</span><br><span class="line">    return wrapTheFunction</span><br></pre></td></tr></table></figure>

<p>测试部分</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">@CalculateTime</span><br><span class="line">def func():</span><br><span class="line">    s &#x3D; 0</span><br><span class="line">    for i in range(10 ** 7):</span><br><span class="line">        s +&#x3D; 1</span><br><span class="line">    print(s)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">if __name__ &#x3D;&#x3D; &#39;__main__&#39;:</span><br><span class="line">    func()</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>结果</p>
<figure class="highlight ada"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">10000000</span></span><br><span class="line"><span class="keyword">Function</span> <span class="title">&quot;func&quot;</span> cost : 1.7449958324432373 <span class="type">second</span>(s).</span><br></pre></td></tr></table></figure>


      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://ackermannn.github.io/2021/04/23/%E7%AE%B1%E5%9E%8B%E5%9B%BE%E6%B3%95%E5%A4%84%E7%90%86%E5%BC%82%E5%B8%B8/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/dl.jpg">
      <meta itemprop="name" content="Ackermannn">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Ackermannn's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2021/04/23/%E7%AE%B1%E5%9E%8B%E5%9B%BE%E6%B3%95%E5%A4%84%E7%90%86%E5%BC%82%E5%B8%B8/" class="post-title-link" itemprop="url">箱型图法处理异常</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2021-04-23 19:30:28" itemprop="dateCreated datePublished" datetime="2021-04-23T19:30:28+08:00">2021-04-23</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2021-09-01 15:23:22" itemprop="dateModified" datetime="2021-09-01T15:23:22+08:00">2021-09-01</time>
      </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/python/" itemprop="url" rel="index"><span itemprop="name">python</span></a>
        </span>
    </span>

  
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Changyan：</span>
    
    
      <a title="changyan" href="/2021/04/23/%E7%AE%B1%E5%9E%8B%E5%9B%BE%E6%B3%95%E5%A4%84%E7%90%86%E5%BC%82%E5%B8%B8/#SOHUCS" itemprop="discussionUrl">
        <span id="url::http://ackermannn.github.io/2021/04/23/%E7%AE%B1%E5%9E%8B%E5%9B%BE%E6%B3%95%E5%A4%84%E7%90%86%E5%BC%82%E5%B8%B8/" class="cy_cmt_count" data-xid="2021/04/23/箱型图法处理异常/" itemprop="commentCount"></span>
      </a>
    
  </span>
  
  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <p>箱型图介绍看链接：</p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/oJiWuXuan/article/details/107815803">Python异常数据处理——箱型图分析</a></p>
<p>一下Python是使用箱型图找到异常值并用线性插值把剔除异常后的缺失填充上。</p>
<h1 id="核心代码"><a href="#核心代码" class="headerlink" title="核心代码"></a>核心代码</h1><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> pandas <span class="keyword">as</span> pd</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">wash_data</span>(<span class="params">df: pd.DataFrame</span>):</span></span><br><span class="line">    <span class="string">&quot;&quot;&quot;箱型图法&quot;&quot;&quot;</span></span><br><span class="line">    q1 = df.quantile(<span class="number">0.25</span>)</span><br><span class="line">    q3 = df.quantile(<span class="number">0.75</span>)</span><br><span class="line">    iqr = q3 - q1</span><br><span class="line">    mi = q1 - <span class="number">1.5</span> * iqr</span><br><span class="line">    ma = q3 + <span class="number">1.5</span> * iqr</span><br><span class="line">    <span class="comment"># error = df[(df &lt; mi) | (df &gt; ma)]</span></span><br><span class="line">    data_c = df[(df &gt;= mi) &amp; (df &lt;= ma)]</span><br><span class="line">    <span class="keyword">return</span> data_c.interpolate().bfill()  <span class="comment"># 线性插值</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h1 id="测试代码"><a href="#测试代码" class="headerlink" title="测试代码"></a>测试代码</h1><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> pandas <span class="keyword">as</span> pd</span><br><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">&#x27;__main__&#x27;</span>:</span><br><span class="line">    df = pd.DataFrame(data=np.random.rand(<span class="number">10</span>, <span class="number">2</span>))</span><br><span class="line">    df[<span class="number">0</span>][<span class="number">1</span>] = <span class="number">100</span></span><br><span class="line">    df[<span class="number">0</span>][<span class="number">2</span>] = <span class="number">99</span></span><br><span class="line">    <span class="built_in">print</span>(df)</span><br><span class="line">    washedDf = wash_data(df)</span><br><span class="line">    <span class="built_in">print</span>(washedDf)</span><br></pre></td></tr></table></figure>
<p>输出结果</p>
<figure class="highlight dns"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line">            <span class="number">0</span>         <span class="number">1</span></span><br><span class="line"><span class="number">0</span>    <span class="number">0.385158</span>  <span class="number">0.469756</span></span><br><span class="line"><span class="number">1</span>  <span class="number">100.000000</span>  <span class="number">0.090029</span></span><br><span class="line"><span class="number">2</span>   <span class="number">99.000000</span>  <span class="number">0.807008</span></span><br><span class="line"><span class="number">3</span>    <span class="number">0.832849</span>  <span class="number">0.672141</span></span><br><span class="line"><span class="number">4</span>    <span class="number">0.965382</span>  <span class="number">0.847540</span></span><br><span class="line"><span class="number">5</span>    <span class="number">0.275084</span>  <span class="number">0.003218</span></span><br><span class="line"><span class="number">6</span>    <span class="number">0.366026</span>  <span class="number">0.211611</span></span><br><span class="line"><span class="number">7</span>    <span class="number">0.462773</span>  <span class="number">0.226748</span></span><br><span class="line"><span class="number">8</span>    <span class="number">0.244522</span>  <span class="number">0.916068</span></span><br><span class="line"><span class="number">9</span>    <span class="number">0.906602</span>  <span class="number">0.029235</span></span><br><span class="line">          <span class="number">0</span>         <span class="number">1</span></span><br><span class="line"><span class="number">0</span>  <span class="number">0.385158</span>  <span class="number">0.469756</span></span><br><span class="line"><span class="number">1</span>  <span class="number">0.534389</span>  <span class="number">0.090029</span></span><br><span class="line"><span class="number">2</span>  <span class="number">0.683619</span>  <span class="number">0.807008</span></span><br><span class="line"><span class="number">3</span>  <span class="number">0.832849</span>  <span class="number">0.672141</span></span><br><span class="line"><span class="number">4</span>  <span class="number">0.965382</span>  <span class="number">0.847540</span></span><br><span class="line"><span class="number">5</span>  <span class="number">0.275084</span>  <span class="number">0.003218</span></span><br><span class="line"><span class="number">6</span>  <span class="number">0.366026</span>  <span class="number">0.211611</span></span><br><span class="line"><span class="number">7</span>  <span class="number">0.462773</span>  <span class="number">0.226748</span></span><br><span class="line"><span class="number">8</span>  <span class="number">0.244522</span>  <span class="number">0.916068</span></span><br><span class="line"><span class="number">9</span>  <span class="number">0.906602</span>  <span class="number">0.029235</span></span><br><span class="line"></span><br><span class="line">进程已结束，退出代码为 <span class="number">0</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>
      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://ackermannn.github.io/2021/04/23/python%E8%AF%BB%E5%8F%96pickle-csv-excel%E6%96%87%E4%BB%B6%E9%80%9F%E5%BA%A6%E5%A4%A7%E6%AF%94%E6%8B%BC/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/dl.jpg">
      <meta itemprop="name" content="Ackermannn">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Ackermannn's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2021/04/23/python%E8%AF%BB%E5%8F%96pickle-csv-excel%E6%96%87%E4%BB%B6%E9%80%9F%E5%BA%A6%E5%A4%A7%E6%AF%94%E6%8B%BC/" class="post-title-link" itemprop="url">python读取pickle,csv,excel文件速度大比拼</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2021-04-23 19:25:34" itemprop="dateCreated datePublished" datetime="2021-04-23T19:25:34+08:00">2021-04-23</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2021-09-01 15:23:22" itemprop="dateModified" datetime="2021-09-01T15:23:22+08:00">2021-09-01</time>
      </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/python/" itemprop="url" rel="index"><span itemprop="name">python</span></a>
        </span>
    </span>

  
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Changyan：</span>
    
    
      <a title="changyan" href="/2021/04/23/python%E8%AF%BB%E5%8F%96pickle-csv-excel%E6%96%87%E4%BB%B6%E9%80%9F%E5%BA%A6%E5%A4%A7%E6%AF%94%E6%8B%BC/#SOHUCS" itemprop="discussionUrl">
        <span id="url::http://ackermannn.github.io/2021/04/23/python%E8%AF%BB%E5%8F%96pickle-csv-excel%E6%96%87%E4%BB%B6%E9%80%9F%E5%BA%A6%E5%A4%A7%E6%AF%94%E6%8B%BC/" class="cy_cmt_count" data-xid="2021/04/23/python读取pickle-csv-excel文件速度大比拼/" itemprop="commentCount"></span>
      </a>
    
  </span>
  
  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <p>进行数据处理时数据量一大，excel文件就力不从心。<br>这次对三个文件格式的读取速度做大比拼。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># -*- coding: UTF-8 -*-</span></span><br><span class="line"><span class="keyword">import</span> time</span><br><span class="line"><span class="keyword">import</span> pandas <span class="keyword">as</span> pd</span><br><span class="line"><span class="string">&quot;&quot;&quot;</span></span><br><span class="line"><span class="string">csv</span></span><br><span class="line"><span class="string">excel</span></span><br><span class="line"><span class="string">pkl</span></span><br><span class="line"><span class="string">速度大比拼</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">&quot;&quot;&quot;</span></span><br><span class="line">start = time.clock()</span><br><span class="line">df = pd.read_pickle(<span class="string">&#x27;table.pkl&#x27;</span>)</span><br><span class="line">elapsed = (time.clock() - start)</span><br><span class="line"><span class="built_in">print</span>(<span class="string">&quot;PKL Time used:&quot;</span>, elapsed)</span><br><span class="line"></span><br><span class="line">start = time.clock()</span><br><span class="line">df = pd.read_csv(<span class="string">&#x27;table.csv&#x27;</span>)</span><br><span class="line">elapsed = (time.clock() - start)</span><br><span class="line"><span class="built_in">print</span>(<span class="string">&quot;CSV Time used:&quot;</span>, elapsed)</span><br><span class="line"></span><br><span class="line">start = time.clock()</span><br><span class="line">df = pd.read_excel(<span class="string">&#x27;table.xlsx&#x27;</span>)</span><br><span class="line">elapsed = (time.clock() - start)</span><br><span class="line"><span class="built_in">print</span>(<span class="string">&quot;EXCEL Time used:&quot;</span>, elapsed)</span><br></pre></td></tr></table></figure>

<h2 id="输出结果"><a href="#输出结果" class="headerlink" title="输出结果"></a>输出结果</h2><figure class="highlight apache"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">PKL</span> Time used: <span class="number">0</span>.<span class="number">0913808</span></span><br><span class="line"><span class="attribute">CSV</span> Time used: <span class="number">0</span>.<span class="number">2128232</span></span><br><span class="line"><span class="attribute">EXCEL</span> Time used: <span class="number">10</span>.<span class="number">9964416</span></span><br></pre></td></tr></table></figure>
<p>pickle完美胜出。参考链接中有大佬的更详细的比拼。</p>
<h1 id="参考"><a href="#参考" class="headerlink" title="参考"></a>参考</h1><p><a target="_blank" rel="noopener" href="https://www.jianshu.com/p/d857c0f472f4">https://www.jianshu.com/p/d857c0f472f4</a></p>

      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://ackermannn.github.io/2020/05/24/postgresql%E4%BD%BF%E7%94%A8%E9%80%9F%E8%AE%B0/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/dl.jpg">
      <meta itemprop="name" content="Ackermannn">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Ackermannn's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2020/05/24/postgresql%E4%BD%BF%E7%94%A8%E9%80%9F%E8%AE%B0/" class="post-title-link" itemprop="url">postgresql使用速记</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2020-05-24 21:58:46" itemprop="dateCreated datePublished" datetime="2020-05-24T21:58:46+08:00">2020-05-24</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2021-09-01 15:23:22" itemprop="dateModified" datetime="2021-09-01T15:23:22+08:00">2021-09-01</time>
      </span>

  
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Changyan：</span>
    
    
      <a title="changyan" href="/2020/05/24/postgresql%E4%BD%BF%E7%94%A8%E9%80%9F%E8%AE%B0/#SOHUCS" itemprop="discussionUrl">
        <span id="url::http://ackermannn.github.io/2020/05/24/postgresql%E4%BD%BF%E7%94%A8%E9%80%9F%E8%AE%B0/" class="cy_cmt_count" data-xid="2020/05/24/postgresql使用速记/" itemprop="commentCount"></span>
      </a>
    
  </span>
  
  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h1 id="基本使用1"><a href="#基本使用1" class="headerlink" title="基本使用1"></a>基本使用<a target="_blank" rel="noopener" href="https://www.jianshu.com/p/34afe4072598">1</a></h1><p>登录</p>
<pre><code>psql -U postgres</code></pre><p>创建数据库用户</p>
<pre><code>CREATE USER user_name WITH PASSWORD &apos;password&apos;;</code></pre><p>创建用户数据库</p>
<pre><code>CREATE DATABASE user_name OWNER user_name;</code></pre><p>给予权限</p>
<pre><code>GRANT ALL PRIVILEGES ON DATABASE user_name to user_name;</code></pre><p>删除用户与数据库</p>
<pre><code>DROP DATABASE user_name;
DROP USER user_name;</code></pre><p>控制台命令</p>
<pre><code>\l 列出所有数据库
\d 列出当前数据库的所有表格
\d [table_name] 列出某一张表格的结构
\c [database_name] 切换数据库
\c - [user_name] 切换用户</code></pre><p>查看数据库占用的物理存储空间大小<a target="_blank" rel="noopener" href="https://www.cnblogs.com/liuyuanyuanGOGO/p/3224554.html">2</a></p>
<p>sql语句查询：</p>
<pre><code>postgres=# select pg_size_pretty(pg_database_size(&apos;postgres&apos;));

pg_size_pretty
----------------
6229 kB
(1 行记录)</code></pre><h1 id="配置PostgreSQL允许远程连接的方法"><a href="#配置PostgreSQL允许远程连接的方法" class="headerlink" title="配置PostgreSQL允许远程连接的方法"></a>配置PostgreSQL允许远程连接的方法</h1><p><a target="_blank" rel="noopener" href="https://blog.csdn.net/u014698745/article/details/86612511?utm_medium=distribute.pc_relevant.none-task-blog-baidujs-6">配置PostgreSQL允许远程连接的方法（PostgreSQL新手入坑）</a></p>
<p>linux 下怎么看postgresql安装到哪个目录了？</p>
<pre><code>psql -U postgres -c &apos;SHOW config_file&apos;</code></pre><p>可参考以下配置文件目录：</p>
<pre><code>sudo vim /var/lib/postgres/data/postgresql.conf
sudo vim /var/lib/postgres/data/pg_hba.conf</code></pre><h1 id="参考"><a href="#参考" class="headerlink" title="参考"></a>参考</h1><p><a target="_blank" rel="noopener" href="https://www.jianshu.com/p/34afe4072598">https://www.jianshu.com/p/34afe4072598</a></p>
<p><a target="_blank" rel="noopener" href="https://www.cnblogs.com/liuyuanyuanGOGO/p/3224554.html">https://www.cnblogs.com/liuyuanyuanGOGO/p/3224554.html</a></p>
<h1 id="踩坑笔记"><a href="#踩坑笔记" class="headerlink" title="踩坑笔记"></a>踩坑笔记</h1><h1 id="1"><a href="#1" class="headerlink" title="1"></a>1</h1><p>如果出现这种情况：</p>
<pre><code>~ &gt;&gt;&gt; psql
psql: error: could not connect to server: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket &quot;/run/postgresql/.s.PGSQL.5432&quot;?</code></pre><p>是根本没启动！！！<br>一个命令可直接启动</p>
<pre><code>sudo systemctl start postgresql.service
sudo systemctl restart postgresql.service</code></pre>
      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://ackermannn.github.io/2020/04/18/python%E5%88%9B%E5%BB%BA%E6%96%87%E4%BB%B6%E5%A4%B9/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/dl.jpg">
      <meta itemprop="name" content="Ackermannn">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Ackermannn's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2020/04/18/python%E5%88%9B%E5%BB%BA%E6%96%87%E4%BB%B6%E5%A4%B9/" class="post-title-link" itemprop="url">python创建文件夹</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2020-04-18 19:04:41" itemprop="dateCreated datePublished" datetime="2020-04-18T19:04:41+08:00">2020-04-18</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2021-09-01 15:23:22" itemprop="dateModified" datetime="2021-09-01T15:23:22+08:00">2021-09-01</time>
      </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/python/" itemprop="url" rel="index"><span itemprop="name">python</span></a>
        </span>
    </span>

  
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Changyan：</span>
    
    
      <a title="changyan" href="/2020/04/18/python%E5%88%9B%E5%BB%BA%E6%96%87%E4%BB%B6%E5%A4%B9/#SOHUCS" itemprop="discussionUrl">
        <span id="url::http://ackermannn.github.io/2020/04/18/python%E5%88%9B%E5%BB%BA%E6%96%87%E4%BB%B6%E5%A4%B9/" class="cy_cmt_count" data-xid="2020/04/18/python创建文件夹/" itemprop="commentCount"></span>
      </a>
    
  </span>
  
  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <p>如果文件夹不存在 创建文件夹</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">if</span> <span class="keyword">not</span> os.path.exists(dirs):</span><br><span class="line">    os.makedirs(dirs)</span><br></pre></td></tr></table></figure>

<h1 id="参考"><a href="#参考" class="headerlink" title="参考"></a>参考</h1><p><a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_39575835/article/details/103974778">https://blog.csdn.net/qq_39575835/article/details/103974778</a></p>

      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://ackermannn.github.io/2020/04/18/python%E4%BF%AE%E6%94%B9%E5%B7%A5%E4%BD%9C%E8%B7%AF%E5%BE%84/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/dl.jpg">
      <meta itemprop="name" content="Ackermannn">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Ackermannn's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2020/04/18/python%E4%BF%AE%E6%94%B9%E5%B7%A5%E4%BD%9C%E8%B7%AF%E5%BE%84/" class="post-title-link" itemprop="url">python修改工作路径</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2020-04-18 18:56:02" itemprop="dateCreated datePublished" datetime="2020-04-18T18:56:02+08:00">2020-04-18</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2021-09-01 15:23:22" itemprop="dateModified" datetime="2021-09-01T15:23:22+08:00">2021-09-01</time>
      </span>

  
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Changyan：</span>
    
    
      <a title="changyan" href="/2020/04/18/python%E4%BF%AE%E6%94%B9%E5%B7%A5%E4%BD%9C%E8%B7%AF%E5%BE%84/#SOHUCS" itemprop="discussionUrl">
        <span id="url::http://ackermannn.github.io/2020/04/18/python%E4%BF%AE%E6%94%B9%E5%B7%A5%E4%BD%9C%E8%B7%AF%E5%BE%84/" class="cy_cmt_count" data-xid="2020/04/18/python修改工作路径/" itemprop="commentCount"></span>
      </a>
    
  </span>
  
  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h1 id="修改工作路径方便测试开发"><a href="#修改工作路径方便测试开发" class="headerlink" title="修改工作路径方便测试开发"></a>修改工作路径方便测试开发</h1><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> os</span><br><span class="line"><span class="comment"># 修改工作路径方便测试开发</span></span><br><span class="line">path = <span class="string">r&quot;C:\Users\Administrator\Documents\GitHub\BF-grading-range\\&quot;</span></span><br><span class="line">os.chdir(path)  <span class="comment"># 也可 ../ 如此切换路径</span></span><br></pre></td></tr></table></figure>

<p>此外</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">os.getcwd() <span class="comment"># 查看工作路径</span></span><br></pre></td></tr></table></figure>

<h1 id="例子二"><a href="#例子二" class="headerlink" title="例子二"></a>例子二</h1><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">chdir</span>():</span></span><br><span class="line">    <span class="comment"># 切换工作路径</span></span><br><span class="line">    <span class="keyword">import</span> os</span><br><span class="line">    path = <span class="string">&quot;../&quot;</span></span><br><span class="line">    os.chdir(path)</span><br><span class="line">    a = os.getcwd()</span><br><span class="line">    <span class="built_in">print</span>(a)</span><br><span class="line">	</span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">&#x27;__main__&#x27;</span>:</span><br><span class="line">    chdir()</span><br></pre></td></tr></table></figure>

<h1 id="参考"><a href="#参考" class="headerlink" title="参考"></a>参考</h1><p><a target="_blank" rel="noopener" href="https://www.runoob.com/python/os-chdir.html">https://www.runoob.com/python/os-chdir.html</a></p>

      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://ackermannn.github.io/2020/04/18/matplotlib%E7%94%BB%E5%9B%BE%E4%B8%AD%E6%96%87%E6%98%BE%E7%A4%BA%E7%9A%84%E9%94%99%E8%AF%AF/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/dl.jpg">
      <meta itemprop="name" content="Ackermannn">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Ackermannn's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2020/04/18/matplotlib%E7%94%BB%E5%9B%BE%E4%B8%AD%E6%96%87%E6%98%BE%E7%A4%BA%E7%9A%84%E9%94%99%E8%AF%AF/" class="post-title-link" itemprop="url">matplotlib画图中文显示的错误</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2020-04-18 18:40:03" itemprop="dateCreated datePublished" datetime="2020-04-18T18:40:03+08:00">2020-04-18</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2021-09-01 15:23:22" itemprop="dateModified" datetime="2021-09-01T15:23:22+08:00">2021-09-01</time>
      </span>

  
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Changyan：</span>
    
    
      <a title="changyan" href="/2020/04/18/matplotlib%E7%94%BB%E5%9B%BE%E4%B8%AD%E6%96%87%E6%98%BE%E7%A4%BA%E7%9A%84%E9%94%99%E8%AF%AF/#SOHUCS" itemprop="discussionUrl">
        <span id="url::http://ackermannn.github.io/2020/04/18/matplotlib%E7%94%BB%E5%9B%BE%E4%B8%AD%E6%96%87%E6%98%BE%E7%A4%BA%E7%9A%84%E9%94%99%E8%AF%AF/" class="cy_cmt_count" data-xid="2020/04/18/matplotlib画图中文显示的错误/" itemprop="commentCount"></span>
      </a>
    
  </span>
  
  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <p>使用python的matplotlib库画图时，xlabel title 会出现中文无法显示的问题。可以参考一下代码解决问题</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> matplotlib <span class="keyword">import</span> pyplot <span class="keyword">as</span> plt</span><br><span class="line"></span><br><span class="line"><span class="comment"># 修补画图时 中文乱码的问题</span></span><br><span class="line">plt.rcParams[<span class="string">&#x27;font.sans-serif&#x27;</span>] = [<span class="string">&#x27;SimHei&#x27;</span>]</span><br><span class="line">plt.rcParams[<span class="string">&#x27;axes.unicode_minus&#x27;</span>] = <span class="literal">False</span></span><br></pre></td></tr></table></figure>
      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://ackermannn.github.io/2020/03/03/Github-Action-%E5%B0%9D%E9%B2%9C/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/dl.jpg">
      <meta itemprop="name" content="Ackermannn">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Ackermannn's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2020/03/03/Github-Action-%E5%B0%9D%E9%B2%9C/" class="post-title-link" itemprop="url">Github Action 尝鲜</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2020-03-03 22:57:26" itemprop="dateCreated datePublished" datetime="2020-03-03T22:57:26+08:00">2020-03-03</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2021-09-01 15:23:22" itemprop="dateModified" datetime="2021-09-01T15:23:22+08:00">2021-09-01</time>
      </span>

  
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Changyan：</span>
    
    
      <a title="changyan" href="/2020/03/03/Github-Action-%E5%B0%9D%E9%B2%9C/#SOHUCS" itemprop="discussionUrl">
        <span id="url::http://ackermannn.github.io/2020/03/03/Github-Action-%E5%B0%9D%E9%B2%9C/" class="cy_cmt_count" data-xid="2020/03/03/Github-Action-尝鲜/" itemprop="commentCount"></span>
      </a>
    
  </span>
  
  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <p>发现GitHub上有个Action功能. 查阅后,感觉它能当成一个远端的服务器用.<br>于是搜寻教程,自动在库 <code>.github/workflows/</code>目录下创建了.yml文件.<br>配置一下这个文件基本就万事大吉了.</p>
<p>主要实现让自己仓库里的文件能在action理运行, 并且让github回传送txt文件</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">name:</span> <span class="string">Run</span> <span class="string">Python</span> <span class="string">&amp;</span> <span class="string">up</span> <span class="string">.txt</span> <span class="string">file</span></span><br><span class="line"><span class="attr">on:</span></span><br><span class="line">  <span class="attr">push:</span></span><br><span class="line">    <span class="attr">branches:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">master</span></span><br><span class="line"><span class="attr">jobs:</span></span><br><span class="line">  <span class="attr">build:</span></span><br><span class="line">    <span class="attr">runs-on:</span> <span class="string">ubuntu-latest</span></span><br><span class="line">    <span class="attr">steps:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="attr">uses:</span> <span class="string">actions/checkout@v2</span></span><br><span class="line">    <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">Set</span> <span class="string">up</span> <span class="string">Python</span> <span class="number">3.8</span></span><br><span class="line">      <span class="attr">uses:</span> <span class="string">actions/setup-python@v1</span></span><br><span class="line">      <span class="attr">with:</span></span><br><span class="line">        <span class="attr">python-version:</span> <span class="number">3.8</span>      </span><br><span class="line">    <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">Run</span> <span class="string">python</span></span><br><span class="line">      <span class="attr">run:</span> <span class="string">|</span></span><br><span class="line">        <span class="string">git</span> <span class="string">clone</span> <span class="string">https://github.com/Ackermannn/TestAction.git</span></span><br><span class="line">        <span class="string">python</span> <span class="string">hello.py</span></span><br><span class="line">    <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">Up</span> <span class="string">something</span></span><br><span class="line">      <span class="attr">run:</span> <span class="string">|</span></span><br><span class="line">        <span class="string">mkdir</span> <span class="string">-p</span> <span class="string">path/to/artifact</span></span><br><span class="line">        <span class="string">echo</span> <span class="string">hello</span> <span class="string">&gt;</span> <span class="string">path/to/artifact/world.txt</span></span><br><span class="line">    <span class="bullet">-</span> <span class="attr">uses:</span> <span class="string">actions/upload-artifact@v1</span></span><br><span class="line">      <span class="attr">with:</span></span><br><span class="line">          <span class="attr">name:</span> <span class="string">my-artifact</span></span><br><span class="line">          <span class="attr">path:</span> <span class="string">path/to/artifact</span></span><br></pre></td></tr></table></figure>

<p>参考链接:</p>
<p><a target="_blank" rel="noopener" href="http://www.ruanyifeng.com/blog/2019/09/getting-started-with-github-actions.html">阮一峰的网络日志:GitHub Actions 入门教程</a></p>
<p><a target="_blank" rel="noopener" href="https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions">action/setup-python的官方文档</a></p>
<p><a target="_blank" rel="noopener" href="https://github.com/actions/upload-artifact">actions/upload-artifact</a></p>

      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/"><i class="fa fa-angle-left" aria-label="上一页"></i></a><a class="page-number" href="/">1</a><span class="page-number current">2</span><a class="page-number" href="/page/3/">3</a><a class="extend next" rel="next" href="/page/3/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
  </nav>


<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      const activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      const commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>
</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Ackermannn</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a> 强力驱动
  </div>

    </div>
  </footer>

  
  <script size="300" alpha="0.6" zIndex="-1" src="https://cdn.jsdelivr.net/npm/ribbon.js@1.0.2/dist/ribbon.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/@next-theme/pjax@0.4.0/pjax.min.js"></script>
<script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script><script>
var pjax = new Pjax({
  selectors: [
    'head title',
    '.page-configurations',
    '.main-inner',
    '.post-toc-wrap',
    '.languages',
    '.pjax'
  ],
  analytics: false,
  cacheBust: false,
  scrollRestoration: false,
  scrollTo: !CONFIG.bookmark.enable
});

document.addEventListener('pjax:success', () => {
  pjax.executeScripts(document.querySelectorAll('script[data-pjax], .pjax script'));
  NexT.boot.refresh();
  // Define Motion Sequence & Bootstrap Motion.
  if (CONFIG.motion.enable) {
    NexT.motion.integrator
      .init()
      .add(NexT.motion.middleWares.subMenu)
      .add(NexT.motion.middleWares.postList)
      .bootstrap();
  }
  const hasTOC = document.querySelector('.post-toc');
  document.querySelector('.sidebar-inner').classList.toggle('sidebar-nav-active', hasTOC);
  document.querySelector(hasTOC ? '.sidebar-nav-toc' : '.sidebar-nav-overview').click();
  NexT.utils.updateSidebarPosition();
});
</script>


  
<script src="/js/local-search.js"></script>





  <script>
    NProgress.configure({
      showSpinner: true
    });
    NProgress.start();
    document.addEventListener('readystatechange', () => {
      if (document.readyState === 'interactive') {
        NProgress.inc(0.8);
      }
      if (document.readyState === 'complete') {
        NProgress.done();
      }
    });
    document.addEventListener('pjax:send', () => {
      NProgress.start();
    });
    document.addEventListener('pjax:success', () => {
      NProgress.done();
    });
  </script>

  



    <div class="pjax">


  <script id="cy_cmt_num" src="https://changyan.sohu.com/upload/plugins/plugins.list.count.js?clientId=cyvq67Edd"></script>


    </div>
</body>
</html>
